<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="wangyuguo">
		<title>操作员管理</title>
		<script type="text/javascript" src="../script/common.js"></script>
		 
		<script type="text/javascript">
			//全局变量
			var qt = null;//数据表格对象
			
			function load() {
				Eui.showNavigation();
				setPages(["resetpassword","editview","listview","detview"]);
			
				searchForm.orgName.value = Common.cOrg().name;
				Common.initDict(searchForm.gender, "gender", "全 部");			//初始化性别(查询form)
				Common.initDict(searchForm.enabled, "enable_status", "全 部");	//初始化状态(查询form)
				createTable()
			}
			//导入司机
			function onImport(){
				var options = {}
				options.headFile = "operator";
				var url = spellUrl("../common/import_data.html",options);
				openDialogFrame(url,"导入操作员",600,800);
			}
			/**查询部分**/
			//创建queryTable
			function createTable() {
				var columns = []
				columns[0] = {type:"checkbox"}
				columns[1] = {render:nameFunc}
				columns[8] = {title:"操作",width:"15",render:operFunc,align:"center",order:false}
				qt = new QueryTable("operator_hq", "searchForm", "datalist", columns, {
					exportable:true,
					//columnsConf:false,
					displayColumns:[0,1,2,3,5,8],
					//forceFit:true,
					buttons:[
						{value:"导 入",actions:onImport},
						{value:"增 加",actions:onEdit},
						{value:"删 除",actions:onDelete},
						{value:"冻 结",actions:lock},
						{value:"解 冻",actions:unlock}
					]
				});
			}
			
			//数据处理方法
			function nameFunc(v, r) {//处理数据 点姓名进入查看页面
				return "<a href='#' onclick=\"onView(" + r[0] + ");return false;\">" + v + "</a>";
			}
			//操作
			function operFunc(v, r) {
				return "<a href='#' onclick=\"onEdit(" + r[0] + ");return false;\">编辑</a>"+" <a href=# onclick=\"resetPswd('" + r[3] + "','" + r[1] + "');return false;\">重置密码</a>";
			}
			
			//数据删除方法
			function onDelete() {
				var ids = qt.getBoxValue();
				Eui.onDel("partyService.deleteOperators",ids, "操作员", null, function() {
					qt.showTable();
				});
			}
			
			//编辑操作员数据
			function onEdit(id) {
				switchPage("editview");
				SystemMgnt.editOperator("editoperator",id);
			}
			
			function photoCallback() {
				switchPage('listview');
				qt.showTable();
			}
			
			//显示明细页面和数据
			function onView(id) {
				switchPage("detview");
				SystemMgnt.showOperator("operatordet",id);
			}
			
			//选择机构方法
			function searchSelOrg(){
				SystemMgnt.selOrg(function(sorg) {
						searchForm.orgName.value = sorg.name;
					},{funcType : Constants.SELORG_ALL});
			}
			
			/**其他页面功能**/
			//显示修改密码页面
			function resetPswd(uniqueId, name) {
				pwdForm.reset();
				pwdForm.uniqueId.value = uniqueId;
				pwdForm.userName.value = name;
				switchPage("resetpassword");
			}
			//新密码保存
			function savePwd() {
				if (!checkForm(pwdForm))return;
				if (pwdForm.newPwd1.value != pwdForm.newPwd2.value) {
					showWarning("新密码和确认新密码不一致！");
					pwdForm.newPwd1.focus();
					return;
				}
				DWR.call("partyService.resetPassword", pwdForm.uniqueId.value, pwdForm.newPwd1.value, function() {
					showInformation("重置密码成功");
					pwdForm.reset();
					switchPage("listview");
				},{blockScreen:true});
			}
			//冻结操作员
			function lock() {
				var ids = qt.getBoxValue();
				if (!ids)
					showWarning("请选择需要冻结的操作员。");
				else {
					if (showQuestion("是否冻结这些操作员？"))
						DWR.call("partyService.lockOperators", ids, function() {
							showInformation("冻结操作员成功");
							qt.showTable();
						},{blockScreen:true});
				}
			}
			//解冻操作员
			function unlock() {
				var ids = qt.getBoxValue();
				if (!ids)
					showWarning("请选择需要解冻的操作员。");
				else {
					if (showQuestion("是否解冻这些操作员？")){
						DWR.call("partyService.unlockOperators", ids, function() {
							showInformation("操作员解冻成功");
							qt.showTable();
						},{blockScreen:true});
					}
				}
			}
			
			function onSave(){
				if (!checkForm(operatorForm)) return;
				var operator = Common.getValues(operatorForm);
				try{
					var v = DWR.syncCall("partyService.saveOperator", operator)
					showInformation("操作员【" + operator.name + "】保存成功")
					if (operator.photoFile) {
						Site.uploadPic(operatorForm, "Operator",v.operator.id, "操作员",
							function(){
								switchPage("listview");
								qt.showTable();
							}
						)
					} else{
						switchPage("listview");
						qt.showTable();
					}
				}catch(e){showError(e.description);return;}
			}
		</script>
	</head>
	<body onload="load()">
		<!--页面导航-->
		<div class="nav">
			<div id="nav">&nbsp;</div>
		</div>
	
		<!--查询&列表-->
		<div id="listview">
			<!--查询form-->
			<div class="searchForm">
				<form id="searchForm" name="searchForm">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="label5">
						<tr>
							<td>
								<label>姓&nbsp;&nbsp;&nbsp;&nbsp;名</label>
								<input type="text" name="name" maxlength="20"/>
							</td>
							<td>
								<label>操作员编码</label>
								<input type="text" name="uniqueId" onblur="checkV(this,'number')" maxlength="10">
							</td>
							<td>
								<label>性&nbsp;&nbsp;&nbsp;&nbsp;别</label>
								<select id="gender" name="gender"><option></option></select>
							</td>
						</tr>
						<tr>
							<td>
								<label>帐&nbsp;&nbsp;&nbsp;&nbsp;号</label>
								<input type="text" name="loginName" maxlength="20">
							</td>
							<td>
								<label>所属机构&nbsp;&nbsp;</label>
								<input type="text" name="orgName" maxlength="20" readonly class="readonly"><a class="orga" href="#" onclick="searchSelOrg();">&nbsp;&nbsp;</a>
							</td>
							<td>
								<label>状&nbsp;&nbsp;&nbsp;&nbsp;态</label>
								<select name="enabled"><option></option></select>
							</td>
							<td><button type="button" onclick="qt.showTable()">查 询</button></td>
						</tr>
					</table>
				</form>
			</div>
		
			<div id="datalist"></div>
		</div>
	
	
		<!--增加/编辑明细页面部分-->
		<div id="editview" style="display:none;">
			<div id="editoperator">
			</div>
			<p>
				<button type="button" onclick="onSave();">保 存</button>
				<button type="button" onclick="switchPage('listview');">返 回</button>
			</p>
		</div>
		
		<!--操作员明细静态页面部分-->
		<div id="detview" style="display:none;">
			<div id="operatordet">
			</div>
			<p>
				<button type="button" onclick="switchPage('listview');">返 回</button>
			</p>
		</div>
	
		<!--修改密码页面部分-->
		<div id="resetpassword" style="display:none;">
			<form id="pwdForm" name="pwdForm">
				<div class="form">
					<div class="formTitle">重置操作员密码</div>
					<input type="hidden" name="uniqueId">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0">
						<tr>
							<td width="100">用户姓名</td>
							<td><input type="text" name="userName" readonly class="readonly"></td>
						</tr>
						<tr>
							<td>新&nbsp;密&nbsp;码</td>
							<td>
								<input type="password" name="newPwd1" maxlength="40" onblur="checkV(this,'',true)">
								<span class="des">*</span>
							</td>
						</tr>
						<tr>
							<td>重复新密码</td>
							<td>
								<input type="password" name="newPwd2" maxlength="40" onblur="checkV(this,'',true)">
								<span class="des">*</span>
							</td>
						</tr>
					</table>
				</div>
				<p>
					<button type="button" name="saveBtn" onclick="savePwd();">保 存</button>
					<button type="button" onclick="switchPage('listview');">取 消</button>
				</p>
			</form>   
		</div>
		<div id="tttt"></div>
	</body>
</html>